/*
 * Created on 11.06.2004
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package de.localsport.util;

import java.sql.Connection;
import java.io.*;
import com.javaexchange.dbConnectionBroker.*;

/**
 * @author Stephan
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class ConnPool {

	private static ConnPool me;	
	private static DbConnectionBroker myBroker;
	
	private static String DRIVER = "com.mysql.jdbc.Driver";
	private static String URL = "jdbc:mysql://127.0.0.1:3306/zoccer?useJvmCharsetConverters=true";
	private static String USER = "root";
	private static String PW = "";
	private static int MIN_CONN = 2;
	private static int MAX_CONN = 5;
	private static double CONN_RESET_TIME = 0.01;
	//private static String LOG = "D:\\JavaWebServer1.1\\DCB_Example1.log";
	
	private ConnPool () {
						
		// The below statement sets up a Broker with a minimun pool size of 2 connections
		// and a maximum of 5.  The log file will be created in 
		// D:\JavaWebServer1.1\DCB_Example.log and the pool connections will be
		// restarted once a day.
		try {myBroker = new DbConnectionBroker(DRIVER, URL, USER, PW, MIN_CONN, MAX_CONN, "", CONN_RESET_TIME);
		} catch (IOException e)  { 
		}
	}

	public static Connection getConnection() {
		
		if (me == null) {
			me = new ConnPool();				
		}
		
		return myBroker.getConnection();
	}
}
